home *** CD-ROM | disk | FTP | other *** search
- Path: news.ifm.liu.se!marcus
- From: marcus@lysator.liu.se (Marcus Comstedt)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Waiting on >1 file
- Date: 16 Mar 1996 18:33:03 GMT
- Message-ID: <4if1gv$1ot@newsy.ifm.liu.se>
- References: <DoB07y.AsM.0.-s@cs.vu.nl>
- NNTP-Posting-Host: tina.lysator.liu.se
- Mime-Version: 1.0
- Content-Type: text/plain; charset=iso-8859-1
- Content-Transfer-Encoding: 8bit
- X-Newsreader: NN version 6.5.0 #24 (NOV)
-
- irmen@cs.vu.nl (Irmen de Jong) writes:
-
- >Say I have more than one file open. In my case all files are (virtual) console
- >files, like CON: or AUX:. What I want to do is to wait on ALL these
- >files simultaneously until one (or more) of them are ready to read, i.e.
- >have input available. dos.library/WaitForChar() only works for one file,
- >i need something like select() on sockets, but on files instead.
-
- You'll have to create a MsgPort, and then post asynchronous ACTION_READ
- or ACTION_WAIT_CHAR packets with dos.library/SendPkt() to all the file
- handlers. Then all you have to is exec.library/WaitPort() and check
- which packets are returned. (Using packets is a little bit hairy, but
- this is the only way I know of...)
-
- >Oh I tried the WaitSelect() from AmiTCP's bsdsocket.library but that
- >beast only works on real sockets, not on normal file descriptors. *sigh*
-
- Using the packet method, you can pass the MsgPort's SigBit to WaitSelect()
- and wait on both files and sockets. I do this in my port of TinyFugue.
-
- --
- --------------------------------------------------------------------------
- Marcus Comstedt Lysator Academic Computer Society
- marcus@lysator.liu.se Linko"ping University, Sweden //
- ----------------------------------------------------------------------\X/-
-